<!-- 后台编辑应用页面 -->
<link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
<link rel="stylesheet" href="/js/lay-module/formSelects/formSelects.css" media="all">
<link rel="stylesheet" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
<link rel="stylesheet" href="/css/public.css" media="all">
<style>
    #upload{
        height: 120px;
        width: 120px;
    }
    #upload img{
        position: absolute;
        width: 120px;
        height: 120px;
    }
    .layui-upload-list{
        margin: 0 !important
    }
    .layui-upload-drag{
        position: absolute;
        padding: 31px;
        border: none;
    }
</style>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="uk-layui-form">
            <form class="layui-form uk-form" action="#">
                <#if data??><input type="hidden" name="id" value="${data.id}"></#if>
<!-- 
                <div class="layui-form-item">
                    <label class="layui-form-label">id：</label>
                    <div class="layui-input-block">
                        <input type="text" name="id" class="layui-input" lay-verify="required"
                            <#if data??>value="${data.id!''}"</#if> placeholder="请输入id" autocomplete="off">
                    </div>
                </div> -->

                <div class="layui-form-item">
                    <label class="layui-form-label">课程号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="cid" class="layui-input" lay-verify="required"
                            <#if data??>value="${data.cid!''}"</#if> placeholder="请输入课程号" autocomplete="off">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">课程名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" class="layui-input" lay-verify="required"
                            <#if data??>value="${data.name!''}"</#if> placeholder="课程名" autocomplete="off">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">课程学分：</label>
                    <div class="layui-input-block">
                        <input type="text" name="coursePoints" class="layui-input" lay-verify="required"
                            <#if data??>value="${data.coursePoints!''}"</#if> placeholder="请输入课程学分" autocomplete="off">
                    </div>
                </div>

           

                <div class="layui-form-item">

                    <label class="layui-form-label">课程总学时：</label>
                    <div class="layui-input-block">
                        <input type="text" name="courseTime" class="layui-input" lay-verify="required"
                            <#if data??>value="${data.courseTime!''}"</#if> placeholder="请输入课程学时" autocomplete="off">
                    </div>
                </div>
           

                <!-- 按钮 -->
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" lay-submit lay-filter="release">更新</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery', 'laydate', 'httpClient','miniTab', 'notice', "upload"], function(){
        var form = layui.form,
            laydate = layui.laydate,
            httpClient = layui.httpClient,
            miniTab = layui.miniTab,
            upload = layui.upload,
            notice = layui.notice,
            $ = layui.jquery;

        // 日期
        laydate.render({
            elem: '#enrolDate',
            type:'date',
            format: 'yyyy-MM-dd',
            trigger: 'click'
        });

        form.on('switch(change)', function(data){
            $('#gender').val(data.elem.checked?'1':'0');
        });

        // 更新
        form.on('submit(release)', function(form){
            let data = form.field;

            httpClient.put('/cur/update', JSON.stringify(data), (response)=>{
                layer.alert(response.msg, { icon: 1, closeBtn: 0 }, function(index) {
                    //关闭弹窗
                    layer.close(index);
                    miniTab.deleteCurrentByIframe();
                });
        });
            return false;
        });
    });
</script>